package com.muyu.controller;

import com.muyu.entity.QueryUserInfoModel;
import com.muyu.entity.UserEntity;
import com.muyu.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

/**
 * @ClassName: UserController
 * @Author: Zirun.Xin
 * @Date: 2025/1/9 9:28
 * @Version: 1.0
 * @Description: 用户控制层
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/user")
@Api(tags = "用户管理模块", description = "用户管理模块")
public class UserController {

    /**
     * 用户业务层
     */
    private final UserService userService;

    /**
     * 获取用户信息
     * @return 响应结果集
     */
    @GetMapping(value = "/get-user-list")
    @ApiOperation(value = "获取用户信息", notes = "获取用户信息")
    public List<UserEntity> getUserList() {
        return userService.getUserList();
    }


    /**
     * 根据多个id等参数联合查询用户信息
     * @param queryUserInfoModel 查询用户参数体集合
     * @return 响应结果集
     */
    @PostMapping(value = "/get-user-by-ids")
    @ApiOperation(value = "根据多个id等参数联合查询用户信息", notes = "根据多个id等参数联合查询用户信息")
    public List<UserEntity> getUserByIds(@RequestBody QueryUserInfoModel queryUserInfoModel) {
        return userService.getUserByIds(queryUserInfoModel.getUserIds());
    }

    /**
     * 根据性别查询用户信息
     * @param sex 性别
     * @return 响应结果集
     */
    @GetMapping(value = "/get-user-by-sex")
    @ApiOperation(value = "根据性别查询用户信息", notes = "根据性别查询用户信息")
    public List<UserEntity> getUserBySex(@ApiParam(value = "性别", required = true)
                                         @RequestParam(value = "sex") String sex) {
        return userService.getUserBySex(sex);
    }
}
